$(document).ready(function(){
    //validate the register (edit) user form on submission.
   $('#form_user_register').bind('submit', function(event){
        //check the first name
        if ($(this).find('input[name="first_name"]').val() == ''){
            alert("Please enter a First Name!");
            return false;
        }
        //check the last name
        if ($(this).find('input[name="last_name"]').val() == ''){
            alert("Please enter a Last Name!");
            return false;
        }
        //check the email
        if ($(this).find('input[name="email"]').val() == ''){
            alert("Please enter an email!");
            return false;
        } else if(!($(this).find('input[name="email"]').val().search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)){
            alert("Please enter a valid email!");
            return false;
        }
        //check the password.
        if ($(this).find('input[name="password"]').val() == ''){
            alert("Please enter a password!");
            return false;
        } else if($(this).find('input[name="password"]').val() != $(this).find('input[name="confirm_password"]').val()){
            alert("The two passwords do not match!");
            return false;
        }
   });
});